//
//  KFDUIConfigurator.m
//  
//
//  Created by JIRENTIANXIANG on 6/14/15.
//
//

#import "KFDUIConfigurator.h"
#import "ui_config.h"

@interface KFDUIConfigurator ()

@property (strong,nonatomic) UIViewController* viewController;

@end

@implementation KFDUIConfigurator

+(KFDUIConfigurator*)configuratorForViewController:(UIViewController *)viewController
{
    KFDUIConfigurator* configurator=[[KFDUIConfigurator alloc] initWithViewController:viewController];
    return configurator;
}

-(instancetype)initWithViewController:(UIViewController*)viewController
{
    if (self=[super init]) {
        self.viewController=viewController;
        viewController.view.tintColor=KFD_RED;
        CGSize size=viewController.view.bounds.size;
        _WIDTH=size.width;
        _HEIGHT=size.height;
        _NAVBAR_HEIGHT=self.viewController.navigationController.navigationBar.frame.size.height;
    }
    return self;
}

-(void)configureNavigationBar
{
    [self configureNavigationBarWithBackAction:nil];
}

-(void)configureNavigationBarWithBackAction:(SEL)backNaviAction
{
    UINavigationBar* navigationBar=_viewController.navigationController.navigationBar;
    navigationBar.barTintColor=KFD_RED;
    navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:[UIColor whiteColor]};
    navigationBar.tintColor=[UIColor whiteColor];
    navigationBar.backIndicatorImage=[UIImage imageNamed:@"header-return-icon"];
    
    if (backNaviAction) {
        _viewController.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"header-return-ico"] style:UIBarButtonItemStylePlain target:_viewController action:backNaviAction];
    }
}

@end
